import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import get_param from '@dfeidao/atom-mobile/nav/get-param';
import render from '@dfeidao/atom-mobile/render/render';
import whoami from '../atom/whoami_getparams';

import a003 from './a003';



export default async function a001(fd: IFeidaoAiMobile) {
	// 初始化
	// 获取系统参数,未登录，获取不到session报错
	const user = await whoami(fd) as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	set(fd, 'productid', user.params.productid);
	const productid = get(fd, 'productid');
	// const teacher_no = user.params.teacher_no;
	const teacher_no = get_param(fd, 'teacher_no');
	set(fd, 'teacher_no', teacher_no);

	const d = await nodejs<{ sex: string, sexing: string, birthday: number, mail_box: string }>('app-basic-information/s001', {
		filter: {
			teacher_no
		},
		page_size: 10,
		page_no: 1,
		productid
	});
	// const b = d.data[0];
	set(fd, 'data', d);
	render(fd, { d });
	await a003(fd, new Date(d.birthday));

}
